UIDocumentInteractionController & ARC: [UIPopoverController dealloc] reached while popover is still visible

Posted by muffel on Stack Overflow See other posts from Stack Overflow or by muffel
Published on 2014-05-27T15:21:42Z Indexed on 2014/05/27 15:25 UTC
Read the original article Hit count: 203

This issue or similar issues have been discussed here before, but I didn't find any working solution for me.

I am using the following code to display a UIDocumentInteractionController on an ARC-enabled iOS 7 project:

- (void) exportDoc{
    // [...]
    docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
    docController.delegate = self;
    [docController presentOpenInMenuFromBarButtonItem:mainMenuButton animated:YES];
}

First I didn't want to create a property that holds the controller reference, but as many people said that there are not alternatives to it. It is defined as

@property (strong) UIDocumentInteractionController* docController;

exportDoc is run in the main thread using NSOperationQueue. Whenever it is executed, I get the following error message:

Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController dealloc] reached while popover is still visible.'

This is what the backtrace says:

(lldb) bt * thread #1: tid = 0x1c97d9, 0x000000019a23c1c0 libobjc.A.dylibobjc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1 frame #0: 0x000000019a23c1c0 libobjc.A.dylibobjc_exception_throw frame #1: 0x000000018d982e90 CoreFoundation+[NSException raise:format:] + 128 frame #2: 0x0000000190bc348c UIKit-[UIPopoverController dealloc] + 96 frame #3: 0x0000000190e18fc8 UIKit-[UIDocumentInteractionController dealloc] + 168 frame #4: 0x000000019a255474 libobjc.A.dylib(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 524 frame #5: 0x000000018d881988 CoreFoundation_CFAutoreleasePoolPop + 28 frame #6: 0x000000018e42cb18 Foundation-[NSOperationInternal _start:] + 892 frame #7: 0x000000018e4eea38 Foundation__NSOQSchedule_f + 76 frame #8: 0x000000019a813fd4 libdispatch.dylib_dispatch_client_callout + 16 frame #9: 0x000000019a8171dc libdispatch.dylib_dispatch_main_queue_callback_4CF + 336 frame #10: 0x000000018d942c2c CoreFoundation__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 12 frame #11: 0x000000018d940f6c CoreFoundation__CFRunLoopRun + 1452 frame #12: 0x000000018d881c20 CoreFoundationCFRunLoopRunSpecific + 452 frame #13: 0x0000000193511c0c GraphicsServicesGSEventRunModal + 168 frame #14: 0x00000001909b2fdc UIKitUIApplicationMain + 1156 * frame #15: 0x000000010000947c MyApplicationmain(argc=1, argv=0x000000016fdfbc80) + 108 at main.m:16 frame #16: 0x000000019a82faa0 libdyld.dylibstart + 4

As far as I understand the autoreleasepool just releases the controller. Shouldn't this be prevented by using a strong property just as I did?

Do you have any idea what the problem can be and how I can solve it?

© Stack Overflow or respective owner

Related posts about ios

Related posts about objective-c